<template>
  <div class="index-container hjPagination">
    <div class="body"  v-for="(item,index) in notesList" :key="index">
      <div class="left">
        <span class="title" v-html="item.name"  @click="navTo('/hj-home/'+tagName+'/detail/'+item.id)"></span>
        <span class="content" v-html="item.content"  @click="navTo('/hj-home/'+tagName+'/detail/'+item.id)"></span>
      </div>
      <div class="right">
        <div class="date">
          <span>{{item.createdAt.substring(8,10)}}</span>
          <span v-if="item.createdAt.substring(5,6) == 0 "> {{item.createdAt.substring(6,7)}}月</span>
          <span v-else-if="item.createdAt.substring(5,6) != 0 "> {{item.createdAt.substring(5,7)}}月</span>
        </div>
        <span class="more"  @click="navTo('/hj-home/'+tagName+'/detail/'+item.id)">MORE+</span>
      </div>
    </div>
    <el-pagination
      :hide-on-single-page="true"
      background
      layout="total, prev, pager, next, jumper"
      :total="total"
      :page-size="queryForm.size"
      @current-change="handleCurrentChange"
      prev-text="上一页"
      next-text="下一页"
    />
  </div>
</template>
<script>
import { notesList } from '../../../api/web/notes.js'
export default {
  name:'index',
  data() {
    return {
      list: [],
      tagName: '',
      total: 0,
      notesList:[],
      queryForm: {
				  page: 0,
				  size: 5,
				  sort: 'createdAt,desc',
				  name: ''
      }
    }
  },
  created() {
    this.tagName = this.$route.meta.tagName
    this.queryList()
  },
  methods: {
    queryList() {
      this.loading = true
      notesList({page:this.queryForm.page,size:5,sort:'createdAt,desc',name:this.queryForm.name}).then(res => {
        this.loading = false
        this.notesList = res.content
        this.total = res.totalElements
      }).catch(_ => {
    	    this.loading = false
    	  })
    },
    submit() {
		this.queryForm.page = 1
		this.queryList()
    },
    handleCurrentChange(val) {
		this.queryForm.page = val-1
		this.queryList()
    }
  }
}
</script>

<style  rel="stylesheet/scss" lang="scss" scoped>
  @import '@/views/website/style/hjPagination.scss';
  .index-container ::v-deep {
    position: relative;
    min-height: 1250px;
    margin: -95px 0 0 40px;
    .el-pagination {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-62%);
    display: flex;
    align-items: center;
    color: #707070;
  }
  }
  .body{
    width: 970px;
    height: 188px;
    border: 1px solid #707070;
    border-radius: 5px;
    display: flex;
    justify-content: space-around;
    margin-bottom: 40px;
    background: #fff;
    .left{
      width: 80%;
      height: 188px;
      padding: 40px;
      .title{
        width: 95%;
        height: 50px;
        font-size: 28px;
        display:block;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        cursor: pointer;
      }
      .content{
        width: 95%;
        line-height: 28px;
        font-size: 18px;
        color: #999999;
        display:block;
        overflow: hidden;
        text-overflow: ellipsis;
        display:-webkit-box;
        -webkit-box-orient:vertical;
        -webkit-line-clamp:2;
        cursor: pointer;
      }
    }
    .right{
      width: 15%;
      height: 188px;
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-top: 40px;
      .date{
      width: 65px;
      height: 63px;
      background: #074489;
      border-radius: 6px;
      font-size: 16px;
      padding: 6px;
      color: #fff;
      display: flex;
      flex-direction: column;
      align-items: center;
      span:nth-child(1) {
        font-size: 25px;
        font-weight: bold;
      }
      span:nth-child(2) {
          font-size: 16px;
          font-weight: 400;
          line-height: 20px;
      }
    }
      .more{
        font-size: 18px;
        color: #444444;
        padding-top: 40px;
        cursor: pointer;
      }
    }

  }
</style>
